#pragma once

#include <string>
#include <list>
#include <thread>
#include <mutex>
#include "srs_librtmp.h"

struct MediaFrame
{
    int nType;
    int8_t* pBuff;
    int nLen;
    bool bKey;
    int64_t timestramp;
};

class libMediaPushWorker
{
public:
	libMediaPushWorker();
	~libMediaPushWorker();
public:
	void MediaCapData_CB(int nType, char* pBuff, int nBuffLen, bool bKeyFrame);
	void Set_SPSAndPPS(unsigned char*sps, long&spslen, unsigned char*pps, long&ppslen);
	void RunPushTH();

	void Init(std::string strUrl);
	void Release();

private:
    srs_rtmp_t m_hRtmpHandle;
	std::thread *m_pThreadPush;
	std::list<MediaFrame*> m_ListMediaData;
	std::mutex m_lockMedia;
	bool m_bInitOK;
	bool m_bExit;

	unsigned char m_sps[100];
	unsigned char m_pps[100];
	long m_spslen;
	long m_ppslen;
};

